<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>条形统计图</title>
  <style>
    canvas {
      border: 1px solid red;

    }
  </style>
</head>

<body>
  <h1>我真的想笑</h1>

  <canvas width="800" height="600"></canvas>
  <script>
    const canvas = document.querySelector('canvas')
    const ctx = canvas.getContext('2d')

    ctx.moveTo(50, 50)
    ctx.lineTo(50, 360)
    ctx.lineTo(800, 360)
    ctx.moveTo(50, 50)
    ctx.lineTo(40, 50)
    ctx.moveTo(50, 110)
    ctx.lineTo(40, 110)
    ctx.moveTo(50, 170)
    ctx.lineTo(40, 170)
    ctx.moveTo(50, 230)
    ctx.lineTo(40, 230)
    ctx.moveTo(50, 290)
    ctx.lineTo(40, 290)
    ctx.moveTo(50, 360)
    ctx.lineTo(40, 360)
    ctx.stroke()


    ctx.moveTo(50, 50)
    ctx.lineTo(800, 50)
    ctx.moveTo(50, 110)
    ctx.lineTo(800, 110)
    ctx.moveTo(50, 170)
    ctx.lineTo(800, 170)
    ctx.moveTo(50, 230)
    ctx.lineTo(800, 230)
    ctx.moveTo(50, 290)
    ctx.lineTo(800, 290)
    ctx.stroke()

    ctx.font = '18px Microsoft Yahei'
    ctx.fillText('150', 30, 50, 20)
    ctx.fillText('120', 30, 110, 20)
    ctx.fillText('90', 30, 170, 20)
    ctx.fillText('60', 30, 230, 20)
    ctx.fillText('30', 30, 290, 20)
    ctx.fillText('0', 30, 360, 20)

    ctx.fillText('食品', 100, 380,)
    ctx.fillText('数码', 300, 380)
    ctx.fillText('服饰', 500, 380)
    ctx.fillText('箱包', 700, 380)

    ctx.fillStyle='red'
    ctx.fillRect(70,170,100,190)
    ctx.fillRect(270,60,100,300)
    ctx.fillRect(470,140,100,220)
    ctx.fillRect(670,220,100,140)


  </script>
</body>

</html>